package com.cloud.shopping.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author John.zhang
 * @version Id: RedisLock, v 1.0 2021/2/8 11:10 ZhiYong Exp $
 */

@Configuration
public class RedisLock {

    /***
     * 创建RedisClient对象
     * 创建锁、解锁
     * @return RedisClient
     */
    @Bean
    public RedissonClient redissonClient(){
        //创建Config
        Config config = new Config();
        //集群实现
        //config.useClusterServers().setScanInterval(2000).addNodeAddress("");
        config.useSingleServer().setAddress("redis://10.181.144.255:6379");
        //创建RedisClient
        return Redisson.create(config);
    }

}
